<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>后台管理系统登录</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.7 -->
		<link rel="stylesheet" href="static/plugins/bower_components/bootstrap/dist/css/bootstrap.min.css">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="static/plugins/bower_components/font-awesome/css/font-awesome.min.css">
		<!-- Ionicons -->
		<link rel="stylesheet" href="static/plugins/bower_components/Ionicons/css/ionicons.min.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="static/dist/css/AdminLTE.min.css">
		<!-- iCheck -->
		<link rel="stylesheet" href="static/plugins/iCheck/square/blue.css">
		<link rel="stylesheet" type="text/css" href="static/plugins/bootstrapvalidator/dist/css/bootstrapValidator.min.css" />
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

		<!-- Google Font -->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<style type="text/css">
			.error1 {
				display: none;
				color: #DD4B39;
			}
			
			.help-block {
				color: #DD4B39;
			}
			#bg{
				background-image: url(static/img/2de20b495bbc1b2c303dd852b73d6e6a.jpg);
				background-size: 100%, 200%;
			}
			#titleColor{
				color: rgba(255,255,255,0.8);
			}
			.login-box-body{
				border-radius: 20px;
				background-color: rgba(255,255,255,0.9);
			}
		</style>
	</head>

	<body class="hold-transition login-page"id="bg">
		<div class="login-box">
			<div class="login-logo"id="titleColor">
				后台管理系统
			</div>
			<!-- /.login-logo -->
			<div class="login-box-body">
				<p class="login-box-msg">用户登录</p>
				<form method="post" id="login" action="/login">
					<div class="form-group has-feedback">
						<input name="Email" type="email" class="form-control Email" placeholder="邮箱">
						<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
						<p class="error1">Email不能为空！</p>
					</div>
					<div class="form-group has-feedback">
						<input name="Password" type="password" class="form-control Password" placeholder="密码">
						<span class="glyphicon glyphicon-lock form-control-feedback"></span>
						<!--<p class="error2">密码不能为空！</p>-->
					</div>
					<div class="row">
						<div class="col-xs-8">
							<div class="checkbox icheck" style="margin-left: 20px;">
								<label>
              <input type="checkbox" name="checkbox" class="remember">记住我
            </label>
							</div>
						</div>
						<!-- /.col -->
						<div class="col-xs-4">
							<!--<button type="submit" class="btn btn-primary btn-block btn-flat login">Sign In</button>-->
							<input type="submit" name="" id="" class="btn btn-primary btn-block btn-flat login" value="登录" />
						</div>
						<!-- /.col -->
					</div>
				</form>
				<a href="#">忘记密码？</a><br>
				<a href="register.html" class="text-center">注册新用户</a>

			</div>
			<!-- /.login-box-body -->
		</div>
		<!-- /.login-box -->

		<!-- jQuery 3 -->
		<script src="static/plugins/bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap 3.3.7 -->
		<script src="static/plugins/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- iCheck -->
		<script src="static/plugins/iCheck/icheck.min.js"></script>
		<script src="static/plugins/bootstrapvalidator/dist/js/bootstrapValidator.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var isgo;
			$(document).ready(function() {
				$("#login").bootstrapValidator({
					fields: {
						Email: {
							validators: {
								notEmpty: {
									message: '邮箱不能为空'
								},
								emailAddress: {
									message: '请输入有效的邮箱地址'
								}
							}
						},
                        Password: {
							validators: {
								notEmpty: {
									message: '密码不能为空'
								},
								stringLength:{
									min: 6,
									max:12,
									message:"请输入长度不少于6位的密码！"
								}
								
							}
						}

					}
				})
				.on('success.field.bv', function(e) {
					e.preventDefault();
					$(".login").click(function() {
					var Email = $(".Email").val();
					var Password = $(".Password").val();
					var remember = $(".remember")[0].checked ? 1 : 0;
						$.ajax({
							type: "post",
							url: "/login",
							data: {
								Email: Email,
								Password: Password,
								remember: remember
							},
							success: function(data) {
								if(data.code==0){
									location.href="/index";
								}
								else{
									$(".error1").css("display", "block");
								    $(".error1").html("Email或者密码错误！");
								}
							}
						});
					return false;
				});
				});
			});
			
		</script>
	</body>

</html>